package com.demo.function.rocketmq.producer;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 展示特殊场景的功能
 * @author cyj
 **/
@Component
public class FuncProducer {

    @Resource(name = "rocketMQTemplate")
    private RocketMQTemplate rocketMqTemplate;

    /**
     * 测试消费端消费失败，broker重试16次，然后将消息放到死信队列
     */
    public void sendConsumerFailMsg() {
        rocketMqTemplate.convertAndSend("consumer-fail-topic", "fail msg, 时间：" + new Date());
    }
}
